package com.zb.factory.controller;

import com.zb.result.Result;
import com.zb.service.ZjFactoryStrategyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author WEN
 * @Date 2024/4/12 0012
 **/
@Api(tags = "品牌商家策略类接口")
@RestController
@RequestMapping("/factory/strategy")
public class ZjFactoryStrategyController {
    @Resource
    private ZjFactoryStrategyService factoryStrategyService;

    @ApiOperation("批量更新开启或关闭工单配件权限")
    @PostMapping("/updateEnableSpareAuthori")
    public Result updateEnableSpareAuthori(@RequestParam @ApiParam(value = "是否开启工单配件权限：false-关闭，true-开启", required = true, example = "false") boolean enableSpareAuthori,
                                           @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableSpareAuthoriBatchById(factoryIds, enableSpareAuthori);
        return Result.success("更新工单配件权限成功");
    }

    @ApiOperation("批量更新开启或关闭申请工单配件")
    @PostMapping("/updateEnableApplySpare")
    public Result updateEnableApplySpare(@RequestParam @ApiParam(value = "是否开启申请工单配件：false-关闭，true-开启", required = true, example = "false") boolean enableSpare,
                                           @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableApplySpareBatchById(factoryIds, enableSpare);
        return Result.success("更新申请工单配件权限成功");
    }

    @ApiOperation("批量更新开启或关闭审核工单配件")
    @PostMapping("/updateEnableCheckSpare")
    public Result updateEnableCheckSpare(@RequestParam @ApiParam(value = "是否开启审核工单配件：false-关闭，true-开启", required = true, example = "false") boolean enableCheckSpare,
                                           @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableCheckSpareBatchById(factoryIds, enableCheckSpare);
        return Result.success("更新审核工单配件权限成功");
    }

    @ApiOperation("批量更新开启或关闭工单费用权限")
    @PostMapping("/updateEnableFeeAuthori")
    public Result updateEnableFeeAuthori(@RequestParam @ApiParam(value = "是否开启工单费用权限：false-关闭，true-开启", required = true, example = "false") boolean enableFeeAuthori,
                                           @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableFeeAuthoriBatchById(factoryIds, enableFeeAuthori);
        return Result.success("更新工单配件权限成功");
    }


    @ApiOperation("批量更新开启或关闭申请工单费用")
    @PostMapping("/updateEnableApplyFee")
    public Result updateEnableApplyFee(@RequestParam @ApiParam(value = "是否开启申请工单费用：false-关闭，true-开启", required = true, example = "false") boolean enableFee,
                                         @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableApplyFeeBatchById(factoryIds, enableFee);
        return Result.success("更新申请工单费用权限成功");
    }

    @ApiOperation("批量更新开启或关闭审核工单费用")
    @PostMapping("/updateEnableCheckFee")
    public Result updateEnableCheckFee(@RequestParam @ApiParam(value = "是否开启审核工单费用：false-关闭，true-开启", required = true, example = "false") boolean enableCheckFee,
                                         @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateEnableCheckFeeBatchById(factoryIds, enableCheckFee);
        return Result.success("更新审核工单费用权限成功");
    }

    @Deprecated
    @ApiOperation("批量更新余额不足报单策略")
    @PostMapping("/updateOrderBalanceStrategy/{orderBalanceStrategy}")
    public Result updateOrderBalanceStrategy(@PathVariable @ApiParam(value = "报单余额策略：1-不限制，2-余额不足禁止下单", required = true, example = "1") Integer orderBalanceStrategy,
                                             @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        return Result.success("更新余额不足报单策略成功");
    }

    @ApiOperation("批量更新结算类型")
    @PostMapping("/updateSettlementType/{settlementType}")
    public Result updateSettlementType(@PathVariable @ApiParam(value = "结算类型：1-预充值，2-月结", required = true, example = "1") Integer settlementType,
                                             @RequestBody @ApiParam(value = "品牌商家ID", required = true) List<Long> factoryIds) {
        factoryStrategyService.updateSettlementTypeBatchById(factoryIds, settlementType);
        return Result.success("更新余额不足报单策略成功");
    }
}
